<!DOCTYPE html>
<html lang="en">
	<head>
	    <meta charset="UTF-8">
	    <script type="text/javascript" src="../assets/js/vue.js" ></script>
	    <title>methods</title>
	</head>
	<body>
		<h1>methods</h1>
		<div id="app">
			{{price}}
			<p></p>
			<button @click='add(2,$event)'>adds</button><p></p>
			<btn @click.native="add(3)"></btn>
		</div>
		<button onclick="app.add(5)">外部 add</button>
	</body>
	
	<script type="application/javascript">

		var btn = {
			template:`<button>组件add</button>`,
			
		}
		
		
		var app = new Vue({
			el:'#app',
			data:{
				price:100
			},
			components:{
				"btn":btn
			},
			methods:{
				add:function(num){
					if(num!=''){
						this.price+=num;
					}else{
						this.price++;					
					}
				}
			}
		})
	</script>
</html>